package io.starteos.wallet.utils.eos.data.remote.model.types;

import io.starteos.wallet.utils.eos.crypto.util.HexUtils;
import io.starteos.wallet.utils.eos.data.remote.model.types.EosType.Writer;

public class EosBuyToken implements EosType.Packer{
	
	
	private TypeAccountName buyer;
	
	private TypeAsset buyToken;
	
	private TypeAsset quantity;
	
	private TypeCoins type;

	public EosBuyToken(String buyer, String buyToken, String quantity, String type) {
		this.buyer = new TypeAccountName(buyer);
		this.buyToken = new TypeAsset(buyToken);
		this.quantity = new TypeAsset(quantity);
		this.type = new TypeCoins(type);
	}
	public String getActionName() {
		return "buytoken";
	}
	@Override
	public void pack(Writer writer) {
		buyer.pack(writer);
		buyToken.pack(writer);
		quantity.pack(writer);
		type.pack(writer);
	}
	
	public String getAsHex() {
		EosType.Writer writer = new EosByteWriter(256);
		pack(writer);
		return HexUtils.toHex(writer.toBytes());
	}
}
